var ajaxHelper = require("../../utils/ajaxhelp");
const serviceUrl = getApp().globalData.serviceUrl;
let token = wx.getStorageSync('token');

const getTaskPage = (pageNum, pageSize, order) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Task/GetTasknfoPagin1", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		pageNum: pageNum,
		pageSize: pageSize,
		order: order
	})
}

const getTaskDetail = (taskid) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Task/GetTaskDetail", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		taskid: taskid
	})
}

const getTaskByNameOrPhineOrLandline = (condition, pageNum, pageSize) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Task/GetTaskByNameOrPhineOrLandline", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		condition: condition,
		pageNum: pageNum,
		pageSize: pageSize
	})
}

const GetScreenNoticeViewData = (taskId) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Task/GetScreenNoticeViewData", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		taskId: taskId
	})
}

const UpdateState = (Id, entityName, state, status) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Task/UpdateState", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		Id: Id,
		entityName: entityName,
		state: state,
		status: status,
	})
}

module.exports = {
	getTaskPage,
	getTaskDetail,
	getTaskByNameOrPhineOrLandline,
	GetScreenNoticeViewData,
	UpdateState
}
